<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>修改</title>
    <link href="../../layuiadmin/js/adm/css/bootstrap.css" rel="stylesheet">
    <script src="../../layuiadmin/js/adm/js/vue.js"></script>
    <script src="../../layuiadmin/js/adm/js/vue-resource.js"></script>
    <script src="../../layuiadmin/js/adm/js/jquery.min.js"></script>
    <script src="../../layuiadmin/js/adm/js/bootstrap.js"></script>
    <script src="../../layuiadmin/js/adm/js/getUrlParam.js"></script>
    <script src="../../layuiadmin/js/adm/js/date.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui@1.4/lib/theme-default/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui@1.4/lib/index.js"></script>
    <script src="../../layuiadmin/js/adm/js/jquery.cookie.js"></script>
</head>
<body>
<div id="app" class="container-fluid" style="padding: 30px 15%">
    <form action="" method="POST" class="form-horizontal form-inline">
        <div class="row">
            <div class="col-md-6">
                <p><b><span style="color: red">*&nbsp;</span>日志类型：</b></p>
                <select class="form-control" style="width: 100%" v-model="logtable.typeId.typeId" @change="postlogejld(logtable.typeId.typeId)">
                    <option v-for="item in logtype" v-if="item.typeId==logtable.typeId.typeId" selected :value="item.typeId">{{item.logStairName}}</option>
                    <option v-for="item in logtype" v-if="item.typeId!=logtable.typeId.typeId"  :value="item.typeId">{{item.logStairName}}</option>
                </select>
            </div>
            <div class="col-md-6">
                <p><b><span style="color: red">*&nbsp;</span>详细类别：</b></p>
                <select class="form-control" style="width: 100%" v-model="logtable.logSecondId.typeId" >
                    <option v-for="item in logtypeej" v-if="item.typeId==logtable.logSecondId.typeId" selected  :value="item.typeId">{{item.logStairName}}</option>
                    <option v-for="item in logtypeej" v-if="item.typeId!=logtable.logSecondId.typeId"    :value="item.typeId">{{item.logStairName}}</option>
                </select>
            </div>
        </div>
        <div class="row" style="margin-top: 30px">
            <div class="col-md-6">
                <p><b><span style="color: red">*&nbsp;</span>案件</b></p>
                <input type="text" class="form-control"  data-toggle="modal" data-target="#mt" v-model="logtable.caseId.caseId" style="width: 100%">
            </div>
            <div class="col-md-6">
                <p><b><span style="color: red">*&nbsp;</span>客户名称：</b></p>
                <input type="text" class="form-control" disabled v-model="logtable.caseId.clientId.clientName" style="width: 100%">
            </div>
        </div>
        <div class="row" style="margin-top: 30px">
            <div class="col-md-6">
                <p><b><span style="color: red">*&nbsp;</span>开始时间：</b></p>
                <input type="datetime-local" class="form-control" disabled v-model="startTime" style="width: 100%">
            </div>
            <div class="col-md-6">
                <p><b><span style="color: red">*&nbsp;</span>结束时间：</b></p>
                <input type="datetime-local" class="form-control" disabled v-model="entTime" style="width: 100%">
            </div>
        </div>

        <div class="row" style="margin-top: 30px">
            <div class="col-md-6">
                <p><b><span style="color: red">*&nbsp;</span>自报时长(时)：</b></p>
                <input type="text" class="form-control" disabled  v-model="logtable.duration" style="width: 100%">
            </div>
            <div class="col-md-6">
                <p><b><span style="color: red">*&nbsp;</span>更新时间：</b></p>
                <input type="date" class="form-control" v-model="logtable.udpatetime" style="width: 100%">
            </div>
        </div>

        <div class="row" style="margin-top: 30px;margin-bottom: 20px">
            <div class="col-md-6">
                <p><b><span style="color: red">*&nbsp;</span>公开状态：</b>
                    <input type="radio" value="N" v-model="logtable.state" name="state">不公开
                    <input type="radio" value="Y" v-model="logtable.state" name="state">公开
                </p>
                <span style="color: red">
                        提示：公开后客户可通过自主查询来查询服务记录
                    </span>
            </div>

        </div>
        <input type="button" class="btn btn-success" value="提交" @click="timesj()">


        <!-- ------------------------------------------------------------------------------------------ -->
        <div class="modal"  id="mt" >
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <span>选择案件</span>
                        <button class="close" data-dismiss="modal">
                            <span>&times;</span>
                        </button>
                    </div>
                    <div class="modal-body" style="height: 500px">
                        <div class="row"  style="padding-left: 20px" >
                            <div class="col-lg-3">
                                <input type="text"  class="form-control" v-model="casetext">
                            </div>
                            <div class="col-lg-3">
                                <select class="form-control" v-model="casequery" >
                                    <option :value="1">案号搜索</option>
                                    <option :value="2">承办律师搜索</option>
                                    <option :value="3">委托人搜索</option>
                                    <option :value="4">对方当事人搜索</option>
                                    <option :value="5">案由搜索</option>
                                    <option :value="6">受理法院搜索</option>
                                </select>
                            </div>


                            <input type="button" class="btn btn-primary" value="搜索"  @click="casequeryc()">
                        </div>

                        <div class="row"  style="padding-left: 20px;margin-top: 30px;" >
                            <table style="width: 97%;border: none;text-align: center" border="1px" >
                                <tr style="height: 50px">
                                    <td><b>选择</b></td>
                                    <td><b>案件号</b></td>
                                    <td><b>委托人</b></td>
                                    <td><b>对方当事人</b></td>
                                    <td><b>承办律师</b></td>
                                    <td><b>收案日期</b></td>
                                </tr>
                                <tr v-for="item in caselsit" style="height: 50px">
                                    <td><input type="radio" id="ca"  name="anjian"  ></td>
                                    <td>{{item.caseId}}</td>
                                    <td>{{item.clientId.clientName}}</td>
                                    <td>{{item.oppositeId.clientName}}</td>
                                    <td>{{item.mainLawyer.empName}}</td>
                                    <td>{{item.closeDate|formatDate}}</td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <input type="button" class="btn btn-primary" @click="submit()" value="确定" data-dismiss="modal">
                        <input type="button" class="btn btn-primary" value="关闭" data-dismiss="modal">
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>


<script>
    var vm=new Vue({
        el:'#app',
        data:{
            logtable:{
                logId:"",
                userId:{
                    userName:""
                },
                typeId:{
                    typeId:"",
                    logStairName:""
                },
                logSecondId:{
                    typeId:"",
                    logStairName:""
                },
                state:"",
                caseId:{
                    caseId:"",
                    clientId:{
                        clientName:""
                    }
                },
                startTime:"",
                entTime:"",
                duration:"",
                udpatetime:"",
                uploading:"",
                description:""
            },
            logtype:[

            ],
            logtypeej:[

            ],
            caselsit:[

            ],
            casetext:"",
            casequery:"1"



        },
        created () {
            var id = getUrlParam("id")
            this.postinfo(id)
            this.postlog()
            this.postlogej(id)
            this.postcase()
        },
        methods: {
            casequeryc(){
                console.log("input框="+this.casetext+"下拉框："+this.casequery)
                this.$http.post('http://localhost:8080/log_table/casequery',{"casetext":this.casetext,"casequery":this.casequery},{emulateJSON:true}).then(result =>{
                    var dat=eval("("+result.body+")")
                        this.caselsit=new Array()   //每次重新new一个list集合给定义的list集合
                        for(var i=0;i<dat.length;i++){
                            this.caselsit.push(dat[i])
                        }

                })
            },
            timesj(){
                if(this.logtable.logSecondId.typeId==undefined){
                    alert("详细类别不能为空")
                }else{
                    var jsons=JSON.stringify(this.logtable)
                    this.$http.post('http://localhost:8080/log_table/timesj',{"data":jsons},{emulateJSON:true}).then(result =>{
                        var i=eval("("+result.body+")")
                        if(i=="1"){
                            alert("修改成功")
                            location.href="log_table.html";
                        }else{
                            alert("修改失败");
                        }
                    })
                }

            },
            submit(){
                var sv=$("input[name='anjian']")
                for(var i = 0;i<sv.length; i++){
                    if(sv[i].checked==true){
                        var c=$(sv[i]).parent().parent().find("td").eq(1).text();
                        this.logtable.caseId.caseId=c
                    }
                }
                this.$http.post("http://localhost:8080/log_table/submit",{"caseId":this.logtable.caseId.caseId},{emulateJSON:true}).then(result =>{
                    this.logtable.caseId.clientId.clientName=result.body
                })
            },
            postcase(){
                this.$http.post("http://localhost:8080/log_table/caselist",{},{emulateJSON:true}).then(result =>{
                    var dat=eval("("+result.body+")")
                    if(dat!=null&&dat!=""){
                        this.caselsit=new Array()   //每次重新new一个list集合给定义的list集合
                        for(var i=0;i<dat.length;i++){
                            this.caselsit.push(dat[i])
                        }
                    }else{
                        alert("获取失败")
                    }
                })
            },
            postinfo(id){
                this.$http.post('http://localhost:8080/log_table/examine',{"id":id},{emulateJSON:true}).then(result =>{
                    var dat=eval("("+result.body+")")
                    this.logtable=dat
                })
            },
            postlog(){    //日志类型
                this.$http.post("http://localhost:8080/log_table/postlog",{},{emulateJSON:true}).then(result =>{
                    var dat=eval("("+result.body+")")
                    if(dat!=null&&dat!=""){
                        this.logtype=new Array()   //每次重新new一个list集合给定义的list集合
                        for(var i=0;i<dat.length;i++){
                            this.logtype.push(dat[i])
                        }
                    }else{
                        alert("获取失败")
                    }
                })
            },
            postlogej(id){    //通过日志类型获取小类型
                this.$http.post('http://localhost:8080/log_table/postlogej',{"id":id},{emulateJSON:true}).then(result =>{
                    var dat=eval("("+result.body+")")
                    if(dat!=null&&dat!=""){
                        this.logtypeej=new Array()   //每次重新new一个list集合给定义的list集合
                        for(var i=0;i<dat.length;i++){
                            this.logtypeej.push(dat[i])
                        }
                    }else{
                        alert("获取失败")
                    }
                })
            },
            postlogejld(id){    //通过日志类型获取小类型
                this.$http.post('http://localhost:8080/log_table/postlogejld',{"id":id},{emulateJSON:true}).then(result =>{
                    var dat=eval("("+result.body+")")
                    if(dat!=null&&dat!=""){
                        this.logtypeej=new Array()   //每次重新new一个list集合给定义的list集合
                        for(var i=0;i<dat.length;i++){
                            this.logtypeej.push(dat[i])
                        }
                        this.logtable.logSecondId.typeId=0
                    }else{
                        alert("获取失败")
                    }
                })
            },

        },
        filters: {
            formatDate: function (value) {      //将时间戳修改为时间单位格式
                let date = new Date(value);
                let y = date.getFullYear();
                let MM = date.getMonth() + 1;
                MM = MM < 10 ? ('0' + MM) : MM;
                let d = date.getDate();
                d = d < 10 ? ('0' + d) : d;
                let h = date.getHours();
                h = h < 10 ? ('0' + h) : h;
                let m = date.getMinutes();
                m = m < 10 ? ('0' + m) : m;
                let s = date.getSeconds();
                s = s < 10 ? ('0' + s) : s;
                return y + '-' + MM + '-' + d ;
                // return y + '-' + MM + '-' + d + 'T' + h + ':' + m ;
            }
        },
        computed: {
            startTime: {		//注意,这里设置的计算规则的命名是页面v-modal绑定的值
                get: function () {      //双向--获取到页面
                    let date = new Date(this.logtable.startTime);//传入需要格式化的值,跟data里的值对应
                    return dateFormat.formatDate(date, "yyyy-MM-ddThh:mm");//调用刚刚写好的js代码格式化
                },
                set: function () {      //双向--获取到后端
                    let date = new Date(this.startTime);//传入需要格式化的值,跟data里的值对应
                    return dateFormat.formatDate(date, "yyyy-MM-dd hh:mm:ss");//调用刚刚写好的js代码格式化
                }
            },
            entTime: {		//注意,这里设置的计算规则的命名是页面v-modal绑定的值
                get: function () {      //双向--获取到页面
                    let date = new Date(this.logtable.entTime);//传入需要格式化的值,跟data里的值对应
                    return dateFormat.formatDate(date, "yyyy-MM-ddThh:mm");//调用刚刚写好的js代码格式化
                },
                set: function () {      //双向--获取到后端
                    let date = new Date(this.entTime);//传入需要格式化的值,跟data里的值对应
                    return dateFormat.formatDate(date, "yyyy-MM-dd hh:mm:ss");//调用刚刚写好的js代码格式化
                }
            }
        }
    })
</script>

</body>
</html>